﻿
Namespace Tools

    Public Class Mime
        Public Function GetValueByExtension(ByVal Ext As String) As String
            Select Case Ext.ToLower()
                Case "323"
                    Return "text/h323"
                Case "acx"
                    Return "application/internet-property-stream"
                Case "ai"
                    Return "application/postscript"
                Case "aif"
                    Return "audio/x-aiff"
                Case "aifc"
                    Return "audio/x-aiff"
                Case "aiff"
                    Return "audio/x-aiff"
                Case "asf"
                    Return "video/x-ms-asf"
                Case "asr"
                    Return "video/x-ms-asf"
                Case "asx"
                    Return "video/x-ms-asf"
                Case "au"
                    Return "audio/basic"
                Case "avi"
                    Return "video/x-msvideo"
                Case "axs"
                    Return "application/olescript"
                Case "bas"
                    Return "text/plain"
                Case "bcpio"
                    Return "application/x-bcpio"
                Case "bin"
                    Return "application/octet-stream"
                Case "bmp"
                    Return "image/bmp"
                Case "c"
                    Return "text/plain"
                Case "cat"
                    Return "application/vnd.ms-pkiseccat"
                Case "cdf"
                    Return "application/x-cdf"
                Case "cer"
                    Return "application/x-x509-ca-cert"
                Case "class"
                    Return "application/octet-stream"
                Case "clp"
                    Return "application/x-msclip"
                Case "cmx"
                    Return "image/x-cmx"
                Case "cod"
                    Return "image/cis-cod"
                Case "cpio"
                    Return "application/x-cpio"
                Case "crd"
                    Return "application/x-mscardfile"
                Case "crl"
                    Return "application/pkix-crl"
                Case "crt"
                    Return "application/x-x509-ca-cert"
                Case "csh"
                    Return "application/x-csh"
                Case "css"
                    Return "text/css"
                Case "dcr"
                    Return "application/x-director"
                Case "der"
                    Return "application/x-x509-ca-cert"
                Case "dir"
                    Return "application/x-director"
                Case "dll"
                    Return "application/x-msdownload"
                Case "dms"
                    Return "application/octet-stream"
                Case "doc"
                    Return "application/msword"
                Case "dot"
                    Return "application/msword"
                Case "dvi"
                    Return "application/x-dvi"
                Case "dxr"
                    Return "application/x-director"
                Case "eps"
                    Return "application/postscript"
                Case "etx"
                    Return "text/x-setext"
                Case "evy"
                    Return "application/envoy"
                Case "exe"
                    Return "application/octet-stream"
                Case "fif"
                    Return "application/fractals"
                Case "flr"
                    Return "x-world/x-vrml"
                Case "gif"
                    Return "image/gif"
                Case "gtar"
                    Return "application/x-gtar"
                Case "gz"
                    Return "application/x-gzip"
                Case "h"
                    Return "text/plain"
                Case "hdf"
                    Return "application/x-hdf"
                Case "hlp"
                    Return "application/winhlp"
                Case "hqx"
                    Return "application/mac-binhex40"
                Case "hta"
                    Return "application/hta"
                Case "htc"
                    Return "text/x-component"
                Case "htm"
                    Return "text/html"
                Case "html"
                    Return "text/html"
                Case "htt"
                    Return "text/webviewhtml"
                Case "ico"
                    Return "image/x-icon"
                Case "ief"
                    Return "image/ief"
                Case "iii"
                    Return "application/x-iphone"
                Case "ins"
                    Return "application/x-internet-signup"
                Case "isp"
                    Return "application/x-internet-signup"
                Case "jfif"
                    Return "image/pipeg"
                Case "jpe"
                    Return "image/jpeg"
                Case "jpeg"
                    Return "image/jpeg"
                Case "jpg"
                    Return "image/jpeg"
                Case "js"
                    Return "application/x-javascript"
                Case "latex"
                    Return "application/x-latex"
                Case "lha"
                    Return "application/octet-stream"
                Case "lsf"
                    Return "video/x-la-asf"
                Case "lsx"
                    Return "video/x-la-asf"
                Case "lzh"
                    Return "application/octet-stream"
                Case "m13"
                    Return "application/x-msmediaview"
                Case "m14"
                    Return "application/x-msmediaview"
                Case "m3u"
                    Return "audio/x-mpegurl"
                Case "man"
                    Return "application/x-troff-man"
                Case "mdb"
                    Return "application/x-msaccess"
                Case "me"
                    Return "application/x-troff-me"
                Case "mht"
                    Return "message/rfc822"
                Case "mhtml"
                    Return "message/rfc822"
                Case "mid"
                    Return "audio/mid"
                Case "mny"
                    Return "application/x-msmoney"
                Case "mov"
                    Return "video/quicktime"
                Case "movie"
                    Return "video/x-sgi-movie"
                Case "mp2"
                    Return "video/mpeg"
                Case "mp3"
                    Return "audio/mpeg"
                Case "mpa"
                    Return "video/mpeg"
                Case "mpe"
                    Return "video/mpeg"
                Case "mpeg"
                    Return "video/mpeg"
                Case "mpg"
                    Return "video/mpeg"
                Case "mpp"
                    Return "application/vnd.ms-project"
                Case "mpv2"
                    Return "video/mpeg"
                Case "ms"
                    Return "application/x-troff-ms"
                Case "mvb"
                    Return "application/x-msmediaview"
                Case "nws"
                    Return "message/rfc822"
                Case "oda"
                    Return "application/oda"
                Case "p10"
                    Return "application/pkcs10"
                Case "p12"
                    Return "application/x-pkcs12"
                Case "p7b"
                    Return "application/x-pkcs7-certificates"
                Case "p7c"
                    Return "application/x-pkcs7-mime"
                Case "p7m"
                    Return "application/x-pkcs7-mime"
                Case "p7r"
                    Return "application/x-pkcs7-certreqresp"
                Case "p7s"
                    Return "application/x-pkcs7-signature"
                Case "pbm"
                    Return "image/x-portable-bitmap"
                Case "pdf"
                    Return "application/pdf"
                Case "pfx"
                    Return "application/x-pkcs12"
                Case "pgm"
                    Return "image/x-portable-graymap"
                Case "pko"
                    Return "application/ynd.ms-pkipko"
                Case "pma"
                    Return "application/x-perfmon"
                Case "pmc"
                    Return "application/x-perfmon"
                Case "pml"
                    Return "application/x-perfmon"
                Case "pmr"
                    Return "application/x-perfmon"
                Case "pmw"
                    Return "application/x-perfmon"
                Case "pnm"
                    Return "image/x-portable-anymap"
                Case "pot,"
                    Return "application/vnd.ms-powerpoint"
                Case "ppm"
                    Return "image/x-portable-pixmap"
                Case "pps"
                    Return "application/vnd.ms-powerpoint"
                Case "ppt"
                    Return "application/vnd.ms-powerpoint"
                Case "prf"
                    Return "application/pics-rules"
                Case "ps"
                    Return "application/postscript"
                Case "pub"
                    Return "application/x-mspublisher"
                Case "qt"
                    Return "video/quicktime"
                Case "ra"
                    Return "audio/x-pn-realaudio"
                Case "ram"
                    Return "audio/x-pn-realaudio"
                Case "ras"
                    Return "image/x-cmu-raster"
                Case "rgb"
                    Return "image/x-rgb"
                Case "rmi"
                    Return "audio/mid"
                Case "roff"
                    Return "application/x-troff"
                Case "rtf"
                    Return "application/rtf"
                Case "rtx"
                    Return "text/richtext"
                Case "scd"
                    Return "application/x-msschedule"
                Case "sct"
                    Return "text/scriptlet"
                Case "setpay"
                    Return "application/set-payment-initiation"
                Case "setreg"
                    Return "application/set-registration-initiation"
                Case "sh"
                    Return "application/x-sh"
                Case "shar"
                    Return "application/x-shar"
                Case "sit"
                    Return "application/x-stuffit"
                Case "snd"
                    Return "audio/basic"
                Case "spc"
                    Return "application/x-pkcs7-certificates"
                Case "spl"
                    Return "application/futuresplash"
                Case "src"
                    Return "application/x-wais-source"
                Case "sst"
                    Return "application/vnd.ms-pkicertstore"
                Case "stl"
                    Return "application/vnd.ms-pkistl"
                Case "stm"
                    Return "text/html"
                Case "svg"
                    Return "image/svg+xml"
                Case "sv4cpio"
                    Return "application/x-sv4cpio"
                Case "sv4crc"
                    Return "application/x-sv4crc"
                Case "swf"
                    Return "application/x-shockwave-flash"
                Case "t"
                    Return "application/x-troff"
                Case "tar"
                    Return "application/x-tar"
                Case "tcl"
                    Return "application/x-tcl"
                Case "tex"
                    Return "application/x-tex"
                Case "texi"
                    Return "application/x-texinfo"
                Case "texinfo"
                    Return "application/x-texinfo"
                Case "tgz"
                    Return "application/x-compressed"
                Case "tif"
                    Return "image/tiff"
                Case "tiff"
                    Return "image/tiff"
                Case "tr"
                    Return "application/x-troff"
                Case "trm"
                    Return "application/x-msterminal"
                Case "tsv"
                    Return "text/tab-separated-values"
                Case "txt"
                    Return "text/plain"
                Case "uls"
                    Return "text/iuls"
                Case "ustar"
                    Return "application/x-ustar"
                Case "vcf"
                    Return "text/x-vcard"
                Case "vrml"
                    Return "x-world/x-vrml"
                Case "wav"
                    Return "audio/x-wav"
                Case "wcm"
                    Return "application/vnd.ms-works"
                Case "wdb"
                    Return "application/vnd.ms-works"
                Case "wks"
                    Return "application/vnd.ms-works"
                Case "wmf"
                    Return "application/x-msmetafile"
                Case "wps"
                    Return "application/vnd.ms-works"
                Case "wri"
                    Return "application/x-mswrite"
                Case "wrl"
                    Return "x-world/x-vrml"
                Case "wrz"
                    Return "x-world/x-vrml"
                Case "xaf"
                    Return "x-world/x-vrml"
                Case "xbm"
                    Return "image/x-xbitmap"
                Case "xla"
                    Return "application/vnd.ms-excel"
                Case "xlc"
                    Return "application/vnd.ms-excel"
                Case "xlm"
                    Return "application/vnd.ms-excel"
                Case "xls"
                    Return "application/vnd.ms-excel"
                Case "xlt"
                    Return "application/vnd.ms-excel"
                Case "xlw"
                    Return "application/vnd.ms-excel"
                Case "xof"
                    Return "x-world/x-vrml"
                Case "xpm"
                    Return "image/x-xpixmap"
                Case "xwd"
                    Return "image/x-xwindowdump"
                Case "z"
                    Return "application/x-compress"
                Case "zip"
                    Return "application/zip"
                Case Else
                    Throw New Exception("Extension not recognized")
            End Select
        End Function
        Public Function GetExtensionByValue(ByVal Value As String) As String
            Select Case Value.ToLower()
                Case "text/h323"
                    Return "323"
                Case "application/internet-property-stream"
                    Return "acx"
                Case "application/postscript"
                    Return "ai"
                Case "audio/x-aiff"
                    Return "aif"
                Case "audio/x-aiff"
                    Return "aifc"
                Case "audio/x-aiff"
                    Return "aiff"
                Case "video/x-ms-asf"
                    Return "asf"
                Case "video/x-ms-asf"
                    Return "asr"
                Case "video/x-ms-asf"
                    Return "asx"
                Case "audio/basic"
                    Return "au"
                Case "video/x-msvideo"
                    Return "avi"
                Case "application/olescript"
                    Return "axs"
                Case "text/plain"
                    Return "bas"
                Case "application/x-bcpio"
                    Return "bcpio"
                Case "application/octet-stream"
                    Return "bin"
                Case "image/bmp"
                    Return "bmp"
                Case "text/plain"
                    Return "c"
                Case "application/vnd.ms-pkiseccat"
                    Return "cat"
                Case "application/x-cdf"
                    Return "cdf"
                Case "application/x-x509-ca-cert"
                    Return "cer"
                Case "application/octet-stream"
                    Return "class"
                Case "application/x-msclip"
                    Return "clp"
                Case "image/x-cmx"
                    Return "cmx"
                Case "image/cis-cod"
                    Return "cod"
                Case "application/x-cpio"
                    Return "cpio"
                Case "application/x-mscardfile"
                    Return "crd"
                Case "application/pkix-crl"
                    Return "crl"
                Case "application/x-x509-ca-cert"
                    Return "crt"
                Case "application/x-csh"
                    Return "csh"
                Case "text/css"
                    Return "css"
                Case "application/x-director"
                    Return "dcr"
                Case "application/x-x509-ca-cert"
                    Return "der"
                Case "application/x-director"
                    Return "dir"
                Case "application/x-msdownload"
                    Return "dll"
                Case "application/octet-stream"
                    Return "dms"
                Case "application/msword"
                    Return "doc"
                Case "application/msword"
                    Return "dot"
                Case "application/x-dvi"
                    Return "dvi"
                Case "application/x-director"
                    Return "dxr"
                Case "application/postscript"
                    Return "eps"
                Case "text/x-setext"
                    Return "etx"
                Case "application/envoy"
                    Return "evy"
                Case "application/octet-stream"
                    Return "exe"
                Case "application/fractals"
                    Return "fif"
                Case "x-world/x-vrml"
                    Return "flr"
                Case "image/gif"
                    Return "gif"
                Case "application/x-gtar"
                    Return "gtar"
                Case "application/x-gzip"
                    Return "gz"
                Case "text/plain"
                    Return "h"
                Case "application/x-hdf"
                    Return "hdf"
                Case "application/winhlp"
                    Return "hlp"
                Case "application/mac-binhex40"
                    Return "hqx"
                Case "application/hta"
                    Return "hta"
                Case "text/x-component"
                    Return "htc"
                Case "text/html"
                    Return "htm"
                Case "text/html"
                    Return "html"
                Case "text/webviewhtml"
                    Return "htt"
                Case "image/x-icon"
                    Return "ico"
                Case "image/ief"
                    Return "ief"
                Case "application/x-iphone"
                    Return "iii"
                Case "application/x-internet-signup"
                    Return "ins"
                Case "application/x-internet-signup"
                    Return "isp"
                Case "image/pipeg"
                    Return "jfif"
                Case "image/jpeg"
                    Return "jpe"
                Case "image/jpeg"
                    Return "jpeg"
                Case "image/jpeg"
                    Return "jpg"
                Case "application/x-javascript"
                    Return "js"
                Case "application/x-latex"
                    Return "latex"
                Case "application/octet-stream"
                    Return "lha"
                Case "video/x-la-asf"
                    Return "lsf"
                Case "video/x-la-asf"
                    Return "lsx"
                Case "application/octet-stream"
                    Return "lzh"
                Case "application/x-msmediaview"
                    Return "m13"
                Case "application/x-msmediaview"
                    Return "m14"
                Case "audio/x-mpegurl"
                    Return "m3u"
                Case "application/x-troff-man"
                    Return "man"
                Case "application/x-msaccess"
                    Return "mdb"
                Case "application/x-troff-me"
                    Return "me"
                Case "message/rfc822"
                    Return "mht"
                Case "message/rfc822"
                    Return "mhtml"
                Case "audio/mid"
                    Return "mid"
                Case "application/x-msmoney"
                    Return "mny"
                Case "video/quicktime"
                    Return "mov"
                Case "video/x-sgi-movie"
                    Return "movie"
                Case "video/mpeg"
                    Return "mp2"
                Case "audio/mpeg"
                    Return "mp3"
                Case "video/mpeg"
                    Return "mpa"
                Case "video/mpeg"
                    Return "mpe"
                Case "video/mpeg"
                    Return "mpeg"
                Case "video/mpeg"
                    Return "mpg"
                Case "application/vnd.ms-project"
                    Return "mpp"
                Case "video/mpeg"
                    Return "mpv2"
                Case "application/x-troff-ms"
                    Return "ms"
                Case "application/x-msmediaview"
                    Return "mvb"
                Case "message/rfc822"
                    Return "nws"
                Case "application/oda"
                    Return "oda"
                Case "application/pkcs10"
                    Return "p10"
                Case "application/x-pkcs12"
                    Return "p12"
                Case "application/x-pkcs7-certificates"
                    Return "p7b"
                Case "application/x-pkcs7-mime"
                    Return "p7c"
                Case "application/x-pkcs7-mime"
                    Return "p7m"
                Case "application/x-pkcs7-certreqresp"
                    Return "p7r"
                Case "application/x-pkcs7-signature"
                    Return "p7s"
                Case "image/x-portable-bitmap"
                    Return "pbm"
                Case "application/pdf"
                    Return "pdf"
                Case "application/x-pkcs12"
                    Return "pfx"
                Case "image/x-portable-graymap"
                    Return "pgm"
                Case "application/ynd.ms-pkipko"
                    Return "pko"
                Case "application/x-perfmon"
                    Return "pma"
                Case "application/x-perfmon"
                    Return "pmc"
                Case "application/x-perfmon"
                    Return "pml"
                Case "application/x-perfmon"
                    Return "pmr"
                Case "application/x-perfmon"
                    Return "pmw"
                Case "image/x-portable-anymap"
                    Return "pnm"
                Case "application/vnd.ms-powerpoint"
                    Return "pot,"
                Case "image/x-portable-pixmap"
                    Return "ppm"
                Case "application/vnd.ms-powerpoint"
                    Return "pps"
                Case "application/vnd.ms-powerpoint"
                    Return "ppt"
                Case "application/pics-rules"
                    Return "prf"
                Case "application/postscript"
                    Return "ps"
                Case "application/x-mspublisher"
                    Return "pub"
                Case "video/quicktime"
                    Return "qt"
                Case "audio/x-pn-realaudio"
                    Return "ra"
                Case "audio/x-pn-realaudio"
                    Return "ram"
                Case "image/x-cmu-raster"
                    Return "ras"
                Case "image/x-rgb"
                    Return "rgb"
                Case "audio/mid"
                    Return "rmi"
                Case "application/x-troff"
                    Return "roff"
                Case "application/rtf"
                    Return "rtf"
                Case "text/richtext"
                    Return "rtx"
                Case "application/x-msschedule"
                    Return "scd"
                Case "text/scriptlet"
                    Return "sct"
                Case "application/set-payment-initiation"
                    Return "setpay"
                Case "application/set-registration-initiation"
                    Return "setreg"
                Case "application/x-sh"
                    Return "sh"
                Case "application/x-shar"
                    Return "shar"
                Case "application/x-stuffit"
                    Return "sit"
                Case "audio/basic"
                    Return "snd"
                Case "application/x-pkcs7-certificates"
                    Return "spc"
                Case "application/futuresplash"
                    Return "spl"
                Case "application/x-wais-source"
                    Return "src"
                Case "application/vnd.ms-pkicertstore"
                    Return "sst"
                Case "application/vnd.ms-pkistl"
                    Return "stl"
                Case "text/html"
                    Return "stm"
                Case "image/svg+xml"
                    Return "svg"
                Case "application/x-sv4cpio"
                    Return "sv4cpio"
                Case "application/x-sv4crc"
                    Return "sv4crc"
                Case "application/x-shockwave-flash"
                    Return "swf"
                Case "application/x-troff"
                    Return "t"
                Case "application/x-tar"
                    Return "tar"
                Case "application/x-tcl"
                    Return "tcl"
                Case "application/x-tex"
                    Return "tex"
                Case "application/x-texinfo"
                    Return "texi"
                Case "application/x-texinfo"
                    Return "texinfo"
                Case "application/x-compressed"
                    Return "tgz"
                Case "image/tiff"
                    Return "tif"
                Case "image/tiff"
                    Return "tiff"
                Case "application/x-troff"
                    Return "tr"
                Case "application/x-msterminal"
                    Return "trm"
                Case "text/tab-separated-values"
                    Return "tsv"
                Case "text/plain"
                    Return "txt"
                Case "text/iuls"
                    Return "uls"
                Case "application/x-ustar"
                    Return "ustar"
                Case "text/x-vcard"
                    Return "vcf"
                Case "x-world/x-vrml"
                    Return "vrml"
                Case "audio/x-wav"
                    Return "wav"
                Case "application/vnd.ms-works"
                    Return "wcm"
                Case "application/vnd.ms-works"
                    Return "wdb"
                Case "application/vnd.ms-works"
                    Return "wks"
                Case "application/x-msmetafile"
                    Return "wmf"
                Case "application/vnd.ms-works"
                    Return "wps"
                Case "application/x-mswrite"
                    Return "wri"
                Case "x-world/x-vrml"
                    Return "wrl"
                Case "x-world/x-vrml"
                    Return "wrz"
                Case "x-world/x-vrml"
                    Return "xaf"
                Case "image/x-xbitmap"
                    Return "xbm"
                Case "application/vnd.ms-excel"
                    Return "xla"
                Case "application/vnd.ms-excel"
                    Return "xlc"
                Case "application/vnd.ms-excel"
                    Return "xlm"
                Case "application/vnd.ms-excel"
                    Return "xls"
                Case "application/vnd.ms-excel"
                    Return "xlt"
                Case "application/vnd.ms-excel"
                    Return "xlw"
                Case "x-world/x-vrml"
                    Return "xof"
                Case "image/x-xpixmap"
                    Return "xpm"
                Case "image/x-xwindowdump"
                    Return "xwd"
                Case "application/x-compress"
                    Return "z"
                Case "application/zip"
                    Return "zip"
                Case Else
                    Throw New Exception("Value not recognized")
            End Select
        End Function
    End Class


End Namespace